<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="user.edit" default="EDIT USER" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home" /></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="user.list" default="USER LIST" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="user.new" default="NEW USER" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="user.edit" default="Edit User" /></h1>
            <g:if test="${flash.message}">
            	<div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}" /></div>
            </g:if>
            <g:hasErrors bean="${userInstance}">
	            <div class="errors">
	                <g:renderErrors bean="${userInstance}" as="list" />
	            </div>
            </g:hasErrors>
            <g:uploadForm>
                <g:hiddenField name="id" value="${userInstance?.id}" />
                <g:hiddenField name="version" value="${userInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
	                        <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="alias"><g:message code="user.alias" default="ALIAS" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'alias', 'errors')}">
                                    <g:textField name="alias" value="${fieldValue(bean: userInstance, field: 'alias')}" />
                                </td>
                                <td rowspan="5">
                                	<img class="detail" width="600px" height="400px" 
                                		src="${resource(dir:userInstance.pathFile,file:userInstance.nameFile +'.'+ userInstance.extFile)}" title="IMAGE" alt="IMAGE"/>
	                            </td>
                            </tr>
 
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="name"><g:message code="user.name" default="NAME" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" value="${fieldValue(bean: userInstance, field: 'name')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="lastName"><g:message code="user.lastName" default="LAST NAME" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'lastName', 'errors')}">
                                    <g:textField name="lastName" value="${fieldValue(bean: userInstance, field: 'lastName')}" />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="email"><g:message code="user.email" default="EMAIL" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'email', 'errors')}">
                                    <g:textField name="email" value="${fieldValue(bean: userInstance, field: 'email')}" />
                                </td>
                            </tr>
                            
                             <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="gender"><g:message code="user.gender" default="GENDER" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'gender', 'errors')}">
                                    <g:checkBox name="gender" value="${userInstance?.gender}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="birdDay"><g:message code="user.birdDay" default="BIRD DAY" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'birdDay', 'errors')}">
                                    <g:datePicker name="birdDay" value="${userInstance?.birdDay}" precision="day" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="country"><g:message code="user.country" default="COUNTRY" />:</label>
                                </td>
                                <td colspan="2" valign="top" class="value ${hasErrors(bean: userInstance, field: 'country', 'errors')}">
									<g:countrySelect name="country" value="${fieldValue(bean:userInstance,field:'country')}"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="password"><g:message code="user.password" default="PASSWORD" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'password', 'errors')}">
                                    <g:textField name="password" value="${fieldValue(bean: userInstance, field: 'password')}" />

                                </td>
                            </tr>
                        
                        	<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="disabled"><g:message code="user.disabled" default="DISABLED" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'disabled', 'errors')}">
                                    <g:checkBox name="disabled" value="${userInstance?.disabled}" />
                                </td>
                            </tr>
                            
                        	<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="rateable"><g:message code="user.rateable" default="RATEABLE" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'rateable', 'errors')}">
                                    <g:checkBox name="rateable" value="${userInstance?.rateable}" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="commentable"><g:message code="user.commentable" default="COMMENTABLE" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'commentable', 'errors')}">
                                    <g:checkBox name="commentable" value="${userInstance?.commentable}" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                        		<td valign="top" class="name">
                        			<label><g:message code="user.path" default="Image Path" />:</label></td>
                        		<td colspan="2" valign="top" class="value ${hasErrors(bean: userInstance, field: 'path', 'errors')}">
                        			<input type="file" name="file"/>
                        		</td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="favoritesComics"><g:message code="user.favoritesComics" default="Favorites Comics" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'favoritesComics', 'errors')}">
									<ul>
										<g:each in="${userInstance?.favoritesComics}" var="comicInstance">
										    <li><g:link controller="comic" action="show" id="${comicInstance.id}">${comicInstance?.encodeAsHTML()}</g:link></li>
										</g:each>
									</ul>
                                </td>
                            </tr>
                            
                            <tr>
                            	<td>
                            		CHANGE PASSWORD
                            	</td>
                            </tr>
                            <tr>
                            	<td>
                            		CHANGE FILE
                            	</td>
                            </tr>
    		        	</tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'update', 'default': 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'delete', 'default': 'Delete')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');" /></span>
                </div>
            </g:uploadForm>
        </div>
    </body>
</html>
